import * as actions from '../actions/format'
import { COMMANDS } from '../../commands'

export default function (keybindings, language) {
  return {
    id: 'formatMenuItem',
    label: language.getString('format'),
    submenu: [{
      id: 'strongMenuItem',
      label: language.getString('bold'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.FORMAT_STRONG),
      click (menuItem, focusedWindow) {
        actions.strong(focusedWindow)
      }
    }, {
      id: 'emphasisMenuItem',
      label: language.getString('italic'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.FORMAT_EMPHASIS),
      click (menuItem, focusedWindow) {
        actions.emphasis(focusedWindow)
      }
    }, {
      id: 'underlineMenuItem',
      label: language.getString('underline'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.FORMAT_UNDERLINE),
      click (menuItem, focusedWindow) {
        actions.underline(focusedWindow)
      }
    }, {
      type: 'separator'
    }, {
      id: 'superscriptMenuItem',
      label: language.getString('superscript'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.FORMAT_SUPERSCRIPT),
      click (menuItem, focusedWindow) {
        actions.superscript(focusedWindow)
      }
    }, {
      id: 'subscriptMenuItem',
      label: language.getString('subscript'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.FORMAT_SUBSCRIPT),
      click (menuItem, focusedWindow) {
        actions.subscript(focusedWindow)
      }
    }, {
      id: 'highlightMenuItem',
      label: language.getString('highlight'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.FORMAT_HIGHLIGHT),
      click (menuItem, focusedWindow) {
        actions.highlight(focusedWindow)
      }
    }, {
      type: 'separator'
    }, {
      id: 'inlineCodeMenuItem',
      label: language.getString('inlineCode'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.FORMAT_INLINE_CODE),
      click (menuItem, focusedWindow) {
        actions.inlineCode(focusedWindow)
      }
    }, {
      id: 'inlineMathMenuItem',
      label: language.getString('inlineMath'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.FORMAT_INLINE_MATH),
      click (menuItem, focusedWindow) {
        actions.inlineMath(focusedWindow)
      }
    }, {
      type: 'separator'
    }, {
      id: 'strikeMenuItem',
      label: language.getString('strikethrough'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.FORMAT_STRIKE),
      click (menuItem, focusedWindow) {
        actions.strikethrough(focusedWindow)
      }
    }, {
      id: 'hyperlinkMenuItem',
      label: language.getString('hyperlink'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.FORMAT_HYPERLINK),
      click (menuItem, focusedWindow) {
        actions.hyperlink(focusedWindow)
      }
    }, {
      id: 'imageMenuItem',
      label: language.getString('image'),
      type: 'checkbox',
      accelerator: keybindings.getAccelerator(COMMANDS.FORMAT_IMAGE),
      click (menuItem, focusedWindow) {
        actions.image(focusedWindow)
      }
    }, {
      type: 'separator'
    }, {
      label: language.getString('clearFormatting'),
      accelerator: keybindings.getAccelerator(COMMANDS.FORMAT_CLEAR_FORMAT),
      click (menuItem, focusedWindow) {
        actions.clearFormat(focusedWindow)
      }
    }]
  }
}
